package com.jctrip.hotel.management.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jctrip.hotel.management.model.param.*;
import com.jctrip.hotel.management.model.result.*;
import com.jctrip.hotel.management.service.RouteInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "management-route")
@RestController
@RequestMapping("/management/route")
public class RouteInfoController {

    @Autowired
    private RouteInfoService routeInfoService;

    @GetMapping("/listRouteCode")
    @ApiOperation(value = "listRouteCode", notes = "获取渠道编码列表")
    @ApiOperationSupport(order = 1)
    public Result<GetRouteCodeResult> listRouteCode(){
        return Result.ok(routeInfoService.listRouteCode());
    }

    @PostMapping("/listName")
    @ApiOperation(value = "listName", notes = "获取渠道列表")
    @ApiOperationSupport(order = 2)
    public Result<GetRouteNameResult> listName(GetRouteNameParam param){
        return Result.ok(routeInfoService.listName(param));
    }

    @PostMapping("/listHotels")
    @ApiModelProperty(value = "listHotels" , notes = "根据参数获取对应酒店")
    @ApiOperationSupport(order = 3)
    public Result<GetHotelListResult> listHotels(@RequestBody GetHotelListParam param){
        return Result.ok(routeInfoService.listhotels(param));
    }

    @GetMapping("/list")
    @ApiOperation(value = "list", notes = "展示所有的供应信息")
    @ApiOperationSupport(order = 4)
    public Result<GetAllRouteListResult> listAllRoutes(@RequestParam(value = "route_code", required = false)String route_code,
                                                       @RequestParam(value = "name", required = false)String name,
                                                       @RequestParam(value = "pageNo", required = false, defaultValue = "1")Long pageNo,
                                                       @RequestParam(value = "pageSize", required = false, defaultValue = "10")Long pageSize){
        return Result.ok(routeInfoService.listAllRoutes(route_code, name, pageNo, pageSize));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "edit", notes = "修改供应信息")
    @ApiOperationSupport(order = 5)
    public Result<String> editRouteInfo(@RequestBody UpdateRouteInfoParam param){
        return Result.ok(routeInfoService.editRouteInfo(param));
    }

    @PostMapping("/add")
    @ApiOperation(value = "add", notes = "添加供应信息")
    @ApiOperationSupport(order = 6)
    public Result<String> addRouteInfo(@RequestBody InsertRouteInfoParam param){
        return Result.ok(routeInfoService.addRouteInfo(param));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "delete", notes = "删除供应信息")
    @ApiOperationSupport(order = 7)
    public Result<String> deleteRouteInfo(@RequestBody RemoveRouteInfoParam param){
        return Result.ok(routeInfoService.deleteRouteInfo(param));
    }
}
